import sys
sys.path.append("../src/scraper/")

from utils import loadBoardNames
from downloadBoard import *
from downloadthread import *
from threadManager import ThreadManager

# Load data from sqlite database
v = ThreadManager("/v/")
v.load()

# if no data, download /v/
if len(v) == 0:
    downloadAndSave("/v/")
    v.load()
else: 
    print("/v/ is already in the database")

# show all saved boards in database
for name in loadBoardNames():
    print(name)

print(f"/v/ has {len(v)} posts saved")

varray = v.createThreadsFromOPs()
print(f"/v/ has {len(varray)} threads saved")

# print all file links
for link in v.getLinks():
    print(link)

# print out all comments
for post in v:
    print(post.getText())